<template>
  <div class="dashboard-container">
    <h3>信息</h3>
    <el-table
      :data="infoData"
      :show-header="false"
      border
      style="width: 100%">
      <el-table-column
        prop="name"
        align="right"
        width="200"/>
      <el-table-column
        align="left"
        prop="val"/>
    </el-table>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Dashboard',
  data() {
    return {
      infoData: []
    }
  },
  computed: {
    ...mapGetters([
      'menus'
    ])
  },
  watch: {
    $route() {
      this.infoData = [
        { name: 'basePath：', val: this.menus.basePath },
        { name: 'host：', val: this.menus.host },
        { name: 'info：', val: `${this.menus.info.title} ${this.menus.info.version}` },
        { name: 'Swagger Version：', val: this.menus.swagger },
        { name: 'API Total：', val: Object.keys(this.menus.paths).length },
        { name: 'Tags Total：', val: this.menus.tags.length }
      ]
    }
  },
  mounted() {
    this.infoData = [
      { name: 'basePath：', val: this.menus.basePath },
      { name: 'host：', val: this.menus.host },
      { name: 'info：', val: `${this.menus.info.title} ${this.menus.info.version}` },
      { name: 'Swagger Version：', val: this.menus.swagger },
      { name: 'API Total：', val: Object.keys(this.menus.paths).length },
      { name: 'Tags Total：', val: this.menus.tags.length }
    ]
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
